<template>
  <div>
    <t-navbar title="MyDiary" :fixed="false" />
    <div >
      <t-fab style="right: 24px;bottom: 80px" :icon="iconFunc" text="日记" @click="tz('/adddiary')" />
    </div>

<!--    <t-pull-down-refresh v-model="refreshing" @refresh="onRefresh">-->
<!--      <t-list :async-loading="loading" @scroll="onScroll">-->
<!--        <t-cell v-for="item in listPull" :key="item" align="middle">-->
<!--          <span class="cell">{{ item }}</span>-->
<!--        </t-cell>-->
<!--      </t-list>-->
<!--    </t-pull-down-refresh>-->




  </div>

  <div>
    <div v-for="(l,index) in diaries" :key="index" style="margin-top: 8px;padding: 15px;border-bottom: 1px solid grey">
      <div style="font-weight: bold">创建时间: {{l.createdTime}}</div>
      <div style="margin-top: 5px">
        <div style="font-size: 12px;color: grey">{{l.createTime}}</div>
        <div style="margin-top: 5px">日记内容:{{l.content}}</div>

      </div>

    </div>

  </div>

<!--  <t-cell>-->
<!--    <span class="cell">{{diaries.createdTime}}</span>-->
<!--    <span class="cell">{{diaries.content}}</span>-->
<!--  </t-cell>-->
  <t-divider content="到底啦" />
</template>

<script setup>
import {ref,onMounted,h} from 'vue'
import { AddIcon } from 'tdesign-icons-vue-next';
import {get,post} from "../util/Request.js";
import {useRouter} from "vue-router";

const iconFunc = () => h(AddIcon, { size: '24px' });

const router=useRouter()

const diaries = ref({
      createdTime:"",
      content:""
})

onMounted(()=>{
  loadData()
})

const loadData=()=>{
  //请求接口 查询我的日记
  get("/diaries/selectByDiaries?userId="+1).then(r=>{
    diaries.value=r.data
  })
}
const tz=(url)=>{
  router.push(url)
}
</script>

<style scoped>

</style>